home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / sgiCD / cdinfo.c next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  63 lines

  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <cdaudio.h>
  4.  
  5.  
  6. main (argc, argv)
  7. int argc;
  8. char *argv[];
  9. {
  10. CDPLAYER *cd;
  11. CDSTATUS status;
  12. CDTRACKINFO info;
  13. int track;
  14.  
  15. fputs ("CDinfo V1.0\n", stdout);
  16. cd = CDopen(0, "r");
  17. if (cd == NULL) {
  18.     perror ("CDopen failed");
  19.     exit (1);
  20.     }
  21.  
  22. /* show info about the entire disk */
  23. if (CDgetstatus(cd, &status) == 0) {
  24.     perror ("CDgetstatus failed");
  25.     CDclose(cd);
  26.     exit (1);
  27.     }
  28. if (status.state != CD_READY) {
  29.     fputs ("The CD player is not ready\n", stderr);
  30.     CDclose(cd);
  31.     exit (1);
  32.     }
  33.  
  34. printf ("The CD drive is Ready.  This drive %s support reading audio data over the SCSI bus\n",
  35.     (status.scsi_audio ? "does" : "DOES NOT"));
  36. printf ("First track = %d, Last track = %d, Total time on disk = %02d:%02d\n\n",
  37.     status.first, status.last, status.total_min, status.total_sec);
  38.  
  39. #ifdef NOTDEF
  40. /*
  41.  * since the current position changed as soon as we called CDgetstatus(),
  42.  * there's not much point in telling the user where we were.
  43.  */
  44. printf ("Current position is at track %d, timecode %02d:%02d, frame %d\n",
  45.     status.track, status.min, status.sec, status.frame);
  46. printf ("Current posision relative to beginning of disk is %02d:%02d, frame %d\n\n",
  47.     status.abs_min, status.abs_sec, status.abs_frame);
  48. #endif /* NOTDEF */
  49.  
  50. /* show info about each track */
  51. for (track = status.first; track <= status.last; track++) {
  52.     if (CDgettrackinfo(cd, track, &info) == 0) {
  53.         perror ("CDgettrackinfo failed");
  54.         break;
  55.         }
  56.     printf ("\tTrack %2d:  Length %02d:%02d\n", track, info.total_min, info.total_sec);
  57.     }
  58.  
  59. fputc ('\n', stdout);
  60. CDclose(cd);
  61. exit (0);
  62. }
  63.